-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(spinner): improve context, action, output, tests #292
base: main
Are you sure you want to change the base?
Conversation
another idea would be to have a type Spinner[T any] struct {
action func () T
// .. and maybe a type Spinner2[T any, Q any] struct {
action func() (T, Q)
} the later being most commonly used as |
@maaslalani I reworked some stuff:
|
Signed-off-by: Carlos Alexandro Becker <[email protected]>
I think this might also fix #196 |
one bad thing about this, is that it might be a breaking change 🤔 |
Can't you support both signature with generics? 🤔 |
Signed-off-by: Carlos Alexandro Becker <[email protected]>
Signed-off-by: Carlos Alexandro Becker <[email protected]>
Signed-off-by: Carlos Alexandro Becker <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
also added the feature from #172 here |
I think I'm missing something obvious here - what's wrong with how we're currently handling actions and how does this change improve that? |
if i recall correctly, if you passed both a context and a function it didn't work properly, that's fixed here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, nice work!
Co-authored-by: Christian Rocha <[email protected]>
Co-authored-by: ccoVeille <[email protected]>
Co-authored-by: ccoVeille <[email protected]>
Co-authored-by: ccoVeille <[email protected]>
This PR started as a small one but grew up as I was finding more problems.
ActionWithError(func(context.Context) error)
, which allows to use the spinner context and return an error, improving error cases usageOutput
to set the output, mainly for testing, but might be useful in more placestea.Cmd
) instead of outside